import routerConfig from '../../page/router';
import routerInit from 'miniapp-router';
Component({
  mixins: [],
  data: {
    userData: [],
    videoData: [],
    rewardData: [],
    mlin:false,
    modalVd: false,
    vdUrl:'', //预览视频
    sales_id:'',
    total: 0,
    page: 1,
    pagesize: 5
  },
  props: {},
  didMount() {
    routerInit.call(this, routerConfig);  //跳转页面初始化
    var params = this.$page.$router.params;
    console.log(this.$page.$router.params)
    this.setData({
      sales_id:params.sales_id
    })
    this.getUserList(params.sales_id);
    this.getUserVideo(params.sales_id);
    this.getUserReward(params.sales_id);
  },
  didUpdate() { },
  didUnmount() { },
  methods: {
    //获取对应用户视频
    getVideo(e){
      var app = getApp();
      var that = this;
      var sales_id = that.data.sales_id;
      var nick = e.target.dataset.name;
      var apiurl = "App.ShopRedsSales.GetDetailsUserVideos";
      var params = { 'pagesize': 20, page: 1 ,sales_id,nick};
      app.xdapis(apiurl, params, function (res) {
        my.hideLoading();
        that.setData({
          videoData: res
        })
        console.log(111111111);
        console.log(that.data.videoData);
      })
    },
    //查看所有
    getAll(){
      var id = this.data.sales_id;
      this.getUserVideo(id);
    },
    //获取用户
    getUserList(sales_id){
      var app = getApp();
      var that = this;
      var apiurl = "App.ShopRedsSales.GetDetailsUser";
      var params = { 'pagesize': 10, page: 1 ,sales_id};
      app.xdapis(apiurl, params, function (res) {
        my.hideLoading();
        that.setData({
          userData: res
        })
        // console.log(that.data.userData);
        // my.alert({ title: JSON.stringify(that.data.userData) });
      });
    },
    //获取用户视频
    getUserVideo(sales_id){
      var app = getApp();
      var that = this;
      var apiurl = "App.ShopRedsSales.GetDetailsUserVideos";
      var params = { 'pagesize': 20, page: 1 ,sales_id};
      app.xdapis(apiurl, params, function (res) {
        my.hideLoading();
        that.setData({
          videoData: res
        })
        console.log(111111111);
        console.log(that.data.videoData);
        // my.alert({ title: JSON.stringify(that.data.userData) });
      });
    },
    //获取用户奖励
    getUserReward(sales_id){
      var app = getApp();
      var that = this;
      var apiurl = "App.ShopRedsSales.GetDetailsUserReward";
      var params = { 'pagesize': 10, page: 1 ,sales_id};
      app.xdapis(apiurl, params, function (res) {
        my.hideLoading();
        that.setData({
          rewardData: res
        })
        console.log(222222222);
        console.log(that.data.rewardData);
        // my.alert({ title: JSON.stringify(that.data.userData) });
      });
    },
     //关闭视频模态框
    closeVideo(e) {
      this.setData({
        modalVd: false,
        vdUrl: '',
      });
    },
    //预览视频
    openVideo(e){
      var src = e.currentTarget.dataset.src;
      this.setData({
        vdUrl: src,
        modalVd: true,
      });
    },
  }
});
